<?php

/**
 * MySql save tables
 *
 * PHP version 5
 *
 * Copyright © 2013 François Cero
 *
 * This file is part of Galette (http://galette.tuxfamily.org).
 *
 * Plugin MySqlsave is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Plugins
 * @package   MySqlsave
 *
 * @author    François Cero <cerol@laposte point net>
 * @copyright 2013 François Cero
 * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
 * @version   0.1
 * @link      http://galette.tuxfamily.org
 * @since     Available since 0.7
 */

define('GALETTE_BASE_PATH', '../../');
require_once GALETTE_BASE_PATH . 'includes/galette.inc.php';
if ( !$login->isLogged() ) {
    header('location: ' . GALETTE_BASE_PATH . 'index.php');
    die();
}
if (!$login->isLogged() && !($login->isAdmin() || $login->isStaff())) {
    header('location: ' . GALETTE_BASE_PATH . 'index.php');
    die();
}
require_once '_config.inc.php';

error_reporting(E_ALL);
ini_set('display_errors', true);

// Instance de la classe 
// Rq: pour les parametres, reprendre une ou plusieurs cles de $default ( dans la methode __construct() )
$SAV = new BackupMySQL(array(
	'host' => HOST_DB,
	'dbname' => NAME_DB,
	'username' => USER_DB,
	'passwd' => PWD_DB,
	'dossier' => './backups/'
	));

$dbName=NAME_DB;
/**
 * Le traitement est terminé, on affiche le template
 */
$tpl->assign('page_title', _T("SAVE.TITLE"));
//Set the path to the current plugin's templates,
//but backup main Galette's template path before
$orig_template_path = $tpl->template_dir;
$tpl->template_dir = 'templates/' . $preferences->pref_theme;

$tpl->assign('sav_tables', $SAV->sauvegarder());
$tpl->assign('sav_listtables', $listtables);
$tpl->assign('sav_msg',$msg);
$tpl->assign('sav_mess',$messsav);
$tpl->assign('sav_prune',$messprune);


$tpl->assign('sav_end', _T("SAVE.MESS1").$dbName. _T("SAVE.MESS2"));


$content = $tpl->fetch('save.tpl', SAVE_SMARTY_PREFIX);
$tpl->assign('content', $content);
//Set path to main Galette's template
$tpl->template_dir = $orig_template_path;
$tpl->display('page.tpl', SAVE_SMARTY_PREFIX);

?>